{include file="public/common" /}


<form class="layui-form" id="order_form">
    <div class="layui-form-item">

        <div class="layui-input-inline">
            <select lay-filter="city1" name="province_id" >
                <option value="">请选择省</option>
            </select>
        </div>
        <div class="layui-input-inline">
            <select lay-filter="city2" name="city_id" >
                <option value="">请选择市</option>
            </select>
        </div>
        <div class="layui-input-inline">
            <select  lay-filter="city" name="county_id">
                <option value="">请选择县/区</option>
            </select>
        </div>

        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" name="community_name" autocomplete="off" class="layui-input" placeholder="搜索...">
            </div>

        </div>


        <div class="layui-inline">
            <button type="submit" class="layui-btn" name="search" value="1">筛选</button>
            <a class="layui-btn" name="export" value="1" onclick="export_data()">导出数据</a>
        </div>
    </div>
</form>

<div>
    <table class="layui-table" width="900px">
        <thead>
        <tr style="text-align: center;">
            <td>省</td>
            <td>市</td>
            <td>区</td>
            <td>地址</td>
            <td>名称</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        {volist name="list_" id="community"}
        <tr style="text-align: center;">
            <td>
                {:city_name($community.province_id)}
            </td>
            <td> {:city_name($community.city_id)}</td>
            <td> {:city_name($community.county_id)}</td>
            <td> {$community.community_address}</td>
            <td> {$community.community_name}</td>
            <td>
                <div style="width: 50%; margin-top: 5px;">
                    <a class="layui-btn layui-btn-small"    href='{:addon_url("admin://community/community_edit")}?id={$community.id}'> 编辑</a>
                    <a class="layui-btn layui-btn-small"    href='{:addon_url("admin://community/community_edit")}?del=1&id={$community.id}'> 删除</a>
                </div>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    {$list_->render()}
</div>

<script>


    layui.use(['form', 'element'], function () {
        var form = layui.form()
                , layer = layui.layer
                , layedit = layui.layedit;
        /**
         * 一级城市
         */
        $.post("/index/tool/city", {"pid": 0}, function (data) {
            if (data.code = 0) {
                return false;
            }
            var html = "";
            $.each(data.data, function (k, v) {
                html += "<option value='" + v.city_id + "'>" + v.city_name + "</option>";
            });
            $("select[lay-filter='city1']").html(html);
            form.render('select');

        });
        /**
         * 二级城市
         */
        form.on('select(city1)', function (data) {
            var val = data.value;
            $.post("/index/tool/city", {"pid": val}, function (data) {
                if (data.code = 0) {
                    return false;
                }
                var html = "";
                html += "<option value=''>下拉选择</option>";
                $.each(data.data, function (k, v) {
                    html += "<option value='" + v.city_id + "'>" + v.city_name + "</option>";
                });
                $("select[lay-filter='city2']").html(html);
                form.render('select');
            });

        });
        /**
         * 三级城市
         */
        form.on('select(city2)', function (data) {
            var val = data.value;
            $.post("/index/tool/city", {"pid": val}, function (data) {
                if (data.code = 0) {
                    return false;
                }
                var html = "";
                html += "<option value=''>下拉选择</option>";
                $.each(data.data, function (k, v) {
                    html += "<option value='" + v.city_id + "'>" + v.city_name + "</option>";
                });
                $("select[lay-filter='city']").html(html);
                form.render('select');
            });
        });

    });

</script>